#!/usr/bin/env python3
# _*_coding:utf-8_*_

"""
@version: 3.5.2
@author: cockroach 
@contact: donnie.fan@gmail.com
@software: PyCharm
@file: ex_code_xmlmod_2.py
@time: 2017/2/27 11:33
"""

import xml.etree.ElementTree as ET

xml_tree = ET.parse('xmltest.xml')
root = xml_tree.getroot()

'''
遍历xml文件
.tag 标签
.attrib 属性
.text 值
'''

for tree_k in root:
    print(tree_k.tag,tree_k.attrib)
    for tree_v in tree_k:
        print(tree_v.tag,tree_v.text)